package com.baidu;

import cn.hutool.core.util.StrUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/hello")
public class Test3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);
        resp.setContentType("text/html;charset=UTF-8");
        String carType = req.getParameter("carType");
        String start = req.getParameter("start");
        String end = req.getParameter("end");
        String size = req.getParameter("size");
        String useTo = req.getParameter("useTo");
        PrintWriter writer = resp.getWriter();
        writer.print("<html>");
        writer.print("<body>");
        writer.println("<h2>注册成功</h2>");
        writer.println(StrUtil.format("<h3>车辆类型为：{}<br>日期：{}-{}<br>数量：{}<br>用途：{}<h3>",carType, start,end,size,useTo));
        writer.println("<h2>3s后跳转</h2>");
        writer.print("</body>");
        writer.print("</html>");
        System.out.println(StrUtil.format("车辆类型为：{}日期：{}-{}数量：{}用途：{}", carType, start, end, size, useTo));
        resp.setHeader("Refresh", "3; url=index.jsp");
        String param1 = req.getParameter("param1");
        System.out.println("接收的参数是："+param1);
//        PrintWriter writer = resp.getWriter();
//        writer.print("<html>");
//        writer.print("<body>");
//        writer.print(StrUtil.format("<h2>你输入的参数是{}</h2>",param1));
//        writer.print("</body>");
//        writer.print("</html>");
//        writer.flush();
    }
}
